Chapter 1: Errors

TACo about Python logo

Errors

Below the code has an error. This is because it is missing " at the end of Hello. This type of error is called a compile-time error. The process of changing Python code into an executable form is called compilation. This means that the rules of Python do not allow these types of errors and are normally found before running, compile-time errors are sometimes called syntax errors. These types of errors cause the compiler to not create an executable program. For an executable program to be created you must first fix the error and then run the program again.
Try writing a few print statements into the Terminal below.




There is another type of error. Try running the code below:


This is called an Exception. Unlike compile-time errors that are found before the code is ran, these types of errors are found when the code is ran. These types of errors are called run-time errors.
The last type of error is called a logic error these happen when the code does something that it's not intended to do. During the development process errors are unavoidable. This could be little things like the misspelling of words, forgetting to add a quotation mark, or trying to perform things like dividing by zero. Fortuity these errors can be found during compile-time and be fixed.
Run-time errors can be more of an issue. It can be much harder to find because the interpreter cannot point out the problem for us. It is up to the program developer to test their programs and correct run-time errors.